/*
 * 类名称:FireExtinguisherDetailServiceImpl.java
 * 包名称:com.platform.service.impl
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2019-09-25 19:51:14        hww     初版做成
 *
 * Copyright (c) 2019-2019 微同科技
 */
package com.platform.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.utils.QueryPlus;
import com.platform.dao.FireExtinguisherDetailDao;
import com.platform.entity.FireExtinguisherDetailEntity;
import com.platform.service.FireExtinguisherDetailService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

/**
 * 灭火器详情（检查记录）Service实现类
 *
 * @author hww
 * @date 2019-09-25 19:51:14
 */
@Service("fireExtinguisherDetailService")
public class FireExtinguisherDetailServiceImpl extends ServiceImpl<FireExtinguisherDetailDao, FireExtinguisherDetailEntity> implements FireExtinguisherDetailService {

    @Override
    public List<FireExtinguisherDetailEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.id");
        params.put("asc", false);
        Page<FireExtinguisherDetailEntity> page = new QueryPlus<FireExtinguisherDetailEntity>(params).getPage();
        List<FireExtinguisherDetailEntity> fireExtinguisherDetailEntities = baseMapper.selectFireExtinguisherDetailPage(page, params);
        return page.setRecords(fireExtinguisherDetailEntities);
    }

    @Override
    public boolean add(FireExtinguisherDetailEntity fireExtinguisherDetail) {
        fireExtinguisherDetail.setInspectTime(new Date());
        fireExtinguisherDetail.setInspectUser("");
        fireExtinguisherDetail.setId("1234567890");
        return this.save(fireExtinguisherDetail);
    }

    @Override
    public boolean update(FireExtinguisherDetailEntity fireExtinguisherDetail) {
        return this.updateById(fireExtinguisherDetail);
    }

    @Override
    public boolean delete(String id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(String[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }
}
